package com.czk.rdd.operator.transform

import org.apache.spark.{SparkConf, SparkContext}
import org.apache.spark.rdd.RDD

/**
 * @Author:ChenZhangKun
 * @Date: 2021/12/10 11:01
 */
object RightJoin {
  def main(args: Array[String]): Unit = {
    val sparkConf = new SparkConf().setMaster("local[*]").setAppName("RDD")
    val sc = new SparkContext(sparkConf)

    val rdd1 = sc.makeRDD(List(("a", 1), ("a", 2), ("a", 3), ("a", 4),("b",5),("c",6)))

    val rdd2= sc.makeRDD(List(("a", 1), ("a", 2), ("a", 3), ("a", 4),("b",5)))
    // 右连接
    val rdd3: RDD[(String, (Option[Int], Int))] = rdd1.rightOuterJoin(rdd2)

    rdd3.collect().foreach(println)
  }
}
